using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using XinBang.BLL;

namespace XinBang.Web
{
    public partial class Default : System.Web.UI.Page
    {
        private ArticleBL ab = new ArticleBL();
        private GoodsBL gb = new GoodsBL();
        private GoodsStrategyBL gsb = new GoodsStrategyBL();
        private TaskBL tb = new TaskBL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                bindSiteNews();
                bindTop10Goods();
                // Bind the recommend goods
                bindGoods(recommendGoods, 3, 8);
                // Bind the daogou goods
                bindGoods(daogou, 2, 5);
                // Bind the new goods
                bindGoods(newGoods, 4, 3);
                // Bind order query
                BindOrderQuery();
                // Bind the Jujia life
                bindGoods(jujia, 5, 5);
                bindGoods(health, 6, 5);
                bindGoods(fashion, 7, 5);
            }
        }

        private void BindOrderQuery()
        {
            orderQuery.DataSource = tb.GetHaveSentOrderList();
            orderQuery.DataBind();
        }

        private void bindGoods(Repeater rep, int strategyid,int size)
        {
            rep.DataSource = gsb.GetGoodsListByStrategyId(strategyid, size);
            rep.DataBind();
        }

        private void bindTop10Goods()
        {
            top10goods.DataSource = gb.GetTop10ByHit();
            top10goods.DataBind();
        }

        private void bindSiteNews()
        {
            shopNews.DataSource = ab.GetTopNArticlesByCatid("2",10);
            shopNews.DataBind();
        }
    }
}
